<template>
	<view class="container">
		<view class="head" :style="{height: `${headHeight}rpx`}">			
			<image :src="'https://www.xrskfw.com/files/xrsk/wxsapp/images/bg.png'" class="head-bg" :style="{height: `${headHeight}rpx`}" />			
		</view>
		<view class="mybox">
			<page-nav class="custom-title" title="我的" :leftShow="false"> </page-nav>
			<view class="user-box">
				<view class="left">
					<image :src="userInfo.avatar" class="avatar" mode=""></image>
				</view>
				<view class="user-name" style=" margin-left: 20rpx; line-height: 128rpx; ">{{ userInfo.nick_name }}
				</view>
			</view>
			<view class="boxer">
				<u-cell-group style="">
					<u-cell size="large"  icon="/static/images/user/qyrz.png" title="企业认证" :isLink="true" arrow-direction="left">
						<text slot="value" class="u-slot-value">去认证</text>
					</u-cell>
					<u-cell size="large" url="/pages/user/apply" icon="https://www.xrskfw.com/static/images/user/about.png" title="我的申请" :isLink="true"
						arrow-direction="left"></u-cell>						
					<u-cell size="large" url="/pages/user/about" icon="https://www.xrskfw.com/static/images/user/about.png" title="关于我们" :isLink="true"
						arrow-direction="left"></u-cell>
					<u-cell size="large" url="/pages/user/connect" icon="https://www.xrskfw.com/static/images/user/kf.png" title="联系我们" :isLink="true"
						arrow-direction="left"></u-cell>
					<u-cell size="large" url="/pages/user/feedback" icon="https://www.xrskfw.com/static/images/user/bzfk.png" title="帮助反馈" :isLink="true"
						arrow-direction="left"></u-cell>
					<u-cell size="large" icon="https://www.xrskfw.com/static/images/user/sz.png" title="设置" :isLink="true" arrow-direction="left"></u-cell>
				</u-cell-group>
			</view>

			<view style="padding: 0rpx 30rpx;">
				<u-button v-if="!this.$u.func.checkLogin({})" style="background-color: #2E69FF; font-weight: 500; margin-bottom: 20rpx;" 
				 @click="gologin" type="primary">登录</u-button>				 
		<!-- 		<u-button  v-if="this.$u.func.checkLogin({})" style="background-color: #2E69FF; font-weight: 500; margin-bottom: 20rpx;" 
				type="primary">切换企业</u-button>		 -->		 
				<u-button  v-if="this.$u.func.checkLogin({})" style="background-color: #2E69FF; font-weight: 500; margin-bottom: 20rpx;"
				  @click="gologout" type="primary">退出登录</u-button>
			</view>
		</view>
		<tab-bar></tab-bar>
	</view>
</template>

<script>
import userinfoVue from './userinfo.vue';
	export default {
		data() {
			return {
				headHeight: 582
			};
		},
		mounted() {
			this.$u.vuex("tabbarIndex",4)
			this.setHeadHeight();
			console.log("checklogin", this.$u.func.checkLogin({}) ) 

		},
		methods: {
			setHeadHeight() {
				const that = this
				// #ifndef H5
				uni.getSystemInfo({
					success: function(res) {
						that.headHeight = Number(res.statusBarHeight) + Number(res.platform == 'ios' ? 44 : 48) + 582
					}
				});
				// #endif
			},
			gologin(){
				uni.navigateTo({
					url: `/pages/login/login-account`
				})
			},
			gologout(){
				this.$u.func.logout();
				uni.navigateTo({
					url: '/pages/user/center'
				})
				 
			}
		}
	};
</script>

<style lang="scss">
	.container {
		background-color: #f7f7f7;
		min-height: 100vh;
		overflow: hidden;
		position: relative;
	}

	.head {
		position: relative;
		top: 0;
		left: 0;
		// z-index: 1;
		min-height: 100vh;
		overflow: hidden;
		// background: #55A2F9;

		.set-icon {
			vertical-align: middle;
			width: 41rpx;
			height: auto;
			margin-right: 35rpx;
		}

		.head-bg {
			position: absolute;
			left: 0px;
			top: 0px;
			// z-index: -1;
			width: 750rpx;
			height: 100vh;
			// background: #55A2F9;
		}
	}

	.mybox {
		position: absolute;
		top: 0; 
		width: 100%;
	}

	.boxer {
		background-color: #FFF;
		margin: 30rpx 30rpx 30rpx 30rpx;
		border-radius: 20rpx;
		padding: 0rpx 10rpx 0rpx 10rpx;
	}

	.user-box {
		display: flex;
		//justify-content: space-between;
		padding: 30rpx 20rpx 0 64rpx;
		//margin-top: 236rpx;

		.left {
			display: flex;
			flex-direction: column;
			align-items: center;

			.avatar {
				width: 128rpx;
				height: 128rpx;
				background: #ffffff;
				border-radius: 50%;
			}

			.user-name {
				background-color: red;
				width: 100%;
				margin-top: 20rpx;
				font-size: 36rpx;
				font-family: Source Han Sans CN;
				font-weight: 500;
				color: #ffffff;
			}

			.tag {
				margin-top: 20rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				padding: 5rpx 16rpx;
				border: 1px solid #f5f5f5;
				border-radius: 7rpx;

				font-size: 19rpx;
				font-family: Source Han Sans CN;
				font-weight: 300;
				color: #ffffff;
			}
		}

		.edit-btn {
			margin-top: 20rpx;
			flex-shrink: 0;
			display: flex;
			justify-content: center;
			align-items: center;

			width: 165rpx;
			height: 54rpx;
			border: 2rpx solid #f5f5f5;
			border-radius: 11rpx;

			font-size: 27rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #ffffff;
		}
	}

	.nav {
		display: flex;
		//border-top: 2rpx solid #7dcdd6;
		margin: 36rpx 38rpx 0;
		padding: 36rpx 0 42rpx;

		.nav-item {
			width: calc(100% / 4);
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: space-between;

			font-size: 25rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #ffffff;

			&:not(:last-of-type) {
				position: relative;

				&::after {
					position: absolute;
					right: 0;
					top: 50%;
					transform: translateY(-50%);
					content: '';
					display: block;
					width: 2rpx;
					background-color: #fff;
					height: 30rpx;
				}
			}

			.icon {
				width: 48rpx;
				height: 48rpx;
				margin-bottom: 6rpx;
			}
		}
	}

	.cell-box {
		background: #ffffff;
		margin: 18rpx;

		.icon {
			width: 32rpx;
			height: 32rpx;
			margin-right: 22rpx;
		}
	}
	
	.u-slot-value{
		background-color: #2E69FF;
		padding:5rpx 20rpx 5rpx 20rpx;
		border-radius: 29rpx;
		color: #FFF;
		font-size: 26rpx;
		font-weight: 500;		
	}
</style>